<!DOCTYPE html>
<html lang="en">
<head>
      <meta charset="UTF-8">
      <meta name="viewport" content="width=device-width, initial-scale=1.0">
      <meta http-equiv="X-UA-Compatible" content="ie=edge">
      <title>登陆</title>
      <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/css/bootstrap.min.css">
      <link rel="stylesheet" href="./stylesheets/register.css">
</head>
<body>
      <!-- logo -->
            <nav class="navbar navbar-default">
                  <div class="container-fluid">
                        <div class="navbar-header">
                              <a class="navbar-brand" href="#">
                                          GP10
                              </a>
                        </div>
                  </div>
            </nav>
      <!-- logo end-->

      <!-- 内容表单  -->
            <div class="container">

                  <div class="row">
                        <div class="col-md-6 col-md-offset-3">
                              <h3>请登录</h3>
                              <form class="login-form" id="login_form"> 
                                    <div class="form-group">
                                          <div class="input-group">
                                          <div class="input-group-addon"><i class="glyphicon glyphicon-user"></i></div>
                                          <input type="text" class="form-control" id="username" placeholder="请输入用户名" >
                                          </div>
                                    </div>
                                    <div class="form-group">
                                          <div class="input-group">
                                          <div class="input-group-addon"><i class="glyphicon glyphicon-lock"></i></div>
                                          <input type="password" class="form-control" id="password" placeholder="请输入密码">
                                          </div>
                                    </div>

                                    <button type="submit" class="btn btn-primary" id="login">登陆</button>
                              </form>
                        </div>
                  </div>

            </div>
      <!-- 内容表单  end-->
      <script src="./common.js"></script>
      <script>

           

            var login = document.getElementById("login");
            var form = document.getElementById("login_form");
            var userIpt = document.getElementById("username");
            var pwdIpt = document.getElementById("password");

            var cookie_user = getCookie("username");
            var cookie_pass = getCookie("tocken");

            // console.log(cookie_pass,cookie_user);
            if(cookie_user && cookie_pass){
                  userIpt.value = cookie_user;
                  pwdIpt.value = cookie_pass;
            }
            // 阻止表单默认事件;
            form.onsubmit = function(evt){
                  var e = evt || window.event;
                  e.preventDefault();
            }
            // 获取数据发送请求;
            login.onclick = function(evt){
                  var username = userIpt.value;
                  var password = pwdIpt.value;
                  console.log(username,password);
                  xhrPost("http://10.9.65.244/group-server/login-server/server/interface/login.php",{
                        username ,
                        password,
                        author: "ty"
                  })
                  .then((res)=>{
                        console.log(res);
                  })
            }
            
      </script>
</body>
</html>